$(function(){
  getNewMsg();
})

//获取知乎日报最新消息
function getNewMsg(){
  $.ajax({
    type: "get",
    url: "https://zhihu-daily.leanapp.cn/api/v1/last-stories",
    data: "",
    dataType: "json",
    success: function (response) {
      // console.log(response.STORIES.date);
      var arr = response.STORIES.stories;
      // console.log(arr.length);
      // for(var i = 0 ;i <arr.length; i++){
      //   console.log(arr[i].images);
      // }
      var str = '';
      arr.forEach(element => {
        // console.log(element.images);
        str += '<li><a href="detail.html?'+element.id
          +'" target="_blank"><img src="'+element.images+
          '" alt=""><span>'
          +element.title+'</span></a></li>';
      });
      $(".zhihu ul").html(str);      
    }    
  });
}

/**
 * 知乎日报API分析
 * http://www.zhimengzhe.com/Javascriptjiaocheng/291451.html
 */